﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
                   assembly="eDirectory.Domain" 
                   namespace="eDirectory.Domain.Entities">
  
  <class name="Customer" table="Customer">
    <id name="Id" type="Int64" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="FirstName" length="50" not-null="true" />
    <property name="LastName" length="50" not-null="true" />
    <property name="Telephone" length="20" not-null="true" />

    <set name ="AddressSet" fetch="subselect">
      <key column="Customer_ID" foreign-key="FK_Customer_Address" not-null="true" />
      <one-to-many class="Address"/>
    </set>
  </class>

  <class name="Address" table="Address">
    <id name="Id" type="Int64" unsaved-value="0">
      <generator class="native" />
    </id>

    <many-to-one name="Customer" class="Customer" column="Customer_ID" not-null="true"/>
    <property name="Street" length="50" not-null="true" />
    <property name="City" length="50" not-null="true" />
    <property name="PostCode" length="10" not-null="true" />
    <property name="Country" length="50" not-null="true" />
  </class>
</hibernate-mapping>
